home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-01-29 | 4.4 KB | 142 lines | [TEXT/IGR0] |
- | WARNING: Routines in this file can kill wave files.
- | See the warnings below. Make sure you understand them before using these procedures.
- | NOTE: These functions works on waves in the current data folder only.
-
- #pragma rtGlobals=1
-
- #include <Strings as Lists>
- #include <Execute Cmd On List>
-
- | KillMatchingWaves(matchStr, flags)
- | matchStr is "*" for all waves or "wave*" for all waves whose name starts with "wave".
- | flags is:
- | bit 0: set to kill wave files (KillWaves/F)
- | WARNING: This can kill wave files. Make sure you know what you are doing.
- | NOTE: This function works on waves in the current data folder only.
- Function KillMatchingWaves(matchStr, flags)
- String matchStr
- Variable flags
-
- String cmdTemplate
-
- if (flags %& 1)
- cmdTemplate = "KillWaves/Z/F %s"
- else
- cmdTemplate = "KillWaves/Z %s"
- endif
- ExecuteCmdOnQuotedList(cmdTemplate, WaveList(matchStr, ";", ""))
- End
-
- | RemoveWavesFromGraph(graphName, matchStr)
- | This is a building-block for RemoveWavesFromWindow.
- | NOTE: This function will not work reliably if the graph contains waves from other than the current data folder.
- Function RemoveWavesFromGraph(graphName, matchStr)
- String graphName | name of a graph
- String matchStr | "*" to remove all waves
-
- String wn
- String wl
- Variable i, offset, type
-
- DoWindow/F $graphName
- if (V_flag)
- wl = WaveList(matchStr, ";", "WIN:") | list of waves in graph and in current data folder
- i = 0
- do
- wn = WaveName(graphName,i,1) | next Y wave in graph
- if (strlen(wn) == 0)
- break | all done
- endif
- offset = FindItemInList(wn, wl, ";", 0)
- if (offset >=0)
- RemoveFromGraph $wn
- else
- i += 1
- endif
- while (1)
- endif
- End
-
- | RemoveWavesFromTable(tableName, matchStr)
- | This is a building-block for RemoveWavesFromWindow.
- | NOTE: This function will not work reliably if the table contains waves from other than the current data folder.
- Function RemoveWavesFromTable(tableName, matchStr)
- String tableName | name of a table
- String matchStr | "*" to remove all waves
-
- String wn
- String wl
- Variable i, offset
-
- DoWindow/F $tableName
- if (V_flag)
- wl = WaveList(matchStr, ";", "WIN:") | list of waves in table
- i = 0
- do
- wn = WaveName(tableName,i,3) | name of next column in table
- if (strlen(wn) == 0)
- break | all done
- endif
- wn = wn[0, strsearch(wn, ".", 0)-1] | get rid of suffix (.x, .y)
- if (CmpStr(wn[0], "'") == 0) | remove single quotes if necessary
- wn = wn[1, strlen(wn)-2]
- endif
- offset = FindItemInList(wn, wl, ";", 0)
- if (offset >=0)
- RemoveFromTable $wn.id
- else
- i += 1
- endif
- while (1)
- endif
- End
-
- | RemoveWavesFromWindow(windowName, matchStr)
- | Removes waves whose names match the matchStr parameter from the named graph or table window.
- | NOTE: This function will not work reliably if the window contains waves from other than the current data folder.
- Function RemoveWavesFromWindow(windowName, matchStr)
- String windowName
- String matchStr | "*" to remove all waves
-
- DoWindow/F $windowName
- if (V_flag)
- if (WinType(windowName) == 1) | this is a graph?
- RemoveWavesFromGraph(windowName, matchStr)
- endif
- if (WinType(windowName) == 2) | this is a table?
- RemoveWavesFromTable(windowName, matchStr)
- endif
- endif
- End
-
- | RemoveWavesFromWindows(winMatchStr, matchStr)
- | Removes matching waves from matching windows.
- | winMatchStr is "*" for all waves or "Graph*" for all waves whose name starts with "Graph".
- | matchStr is "*" for all waves or "wave*" for all waves whose name starts with "wave".
- | NOTE: This function will not work reliably if the windows contain waves from other than the current data folder.
- Function RemoveWavesFromWindows(winMatchStr, waveMatchStr)
- String winMatchStr | "*" for all windows
- String waveMatchStr | "*" to remove all waves
-
- String cmdTemplate
- sprintf cmdTemplate, "RemoveWavesFromWindow(\"%%s\", \"%s\")", waveMatchStr
- ExecuteCmdOnList(cmdTemplate, WinList(winMatchStr,";","WIN:3"))
- End
-
- | KillAllWaves(flags)
- | Optionally, removes all waves from all graphs and tables.
- | Then kills all waves that are not in use.
- | flags is:
- | bit 0: set to kill wave files (KillWaves/F)
- | bit 1: set to remove all waves from graphs and tables
- | WARNING: This can kill wave files. Make sure you know what you are doing.
- | NOTE: This function works on waves in the current data folder only.
- Function KillAllWaves(flags)
- Variable flags
-
- if (flags %& 2)
- RemoveWavesFromWindows("*", "*")
- endif
- KillMatchingWaves("*", flags)
- End
-